// ==UserScript==
// @name         kf007-客服自动取号
// @namespace    https://kf.007.tools/s/ujmGLoMX&o=0593
// @version      1.3.18
// @description  try to take over the world!
// @author       Yaodecheng
// @match        https://kf.007.tools/shared-order*
// @match        http://*/share/share/index.html*
// @match        https://qihang16.8888ws.net/agent/index.html*
// @match        https://007.mn/staff-share-list*
// @match        https://007.mn/ws-add-fans-detail-share-list*
// @match        https://007.mn/shated-staff-list*
// @match        https://007.ma/ws-add-fans-detail-share-list*
// @match        https://imx.chat/ws-add-fans-detail-share-list*
// @match        https://imx.chat/work-order-sharing*
// @match        https://admin.scrmchampion.com/shared-order*
// @match        https://app.imx.chat/work-order-sharing*
// @match        https://app.imx.chat/ws-add-fans-detail-share-list?*
// @match        https://*/share/share/index.html*
// @match        https://www.haiwang.app/web
// @match        https://app.imx.chat/staff-share-list*
// @match        http://url66.me/s*
// @match        https://app.imx.chat/shated-staff-list*
// @match        https://admin.scrmchampion.com/share-activation-code/*
// @icon         https://www.iconfont.cn/favicon.ico
// @grant        none
// @updateURL https://gitee.com/YaoDecheng/kf_zhanghao/raw/master/kf007-autoget.js
// @downloadURL https://gitee.com/YaoDecheng/kf_zhanghao/raw/master/kf007-autoget.js
// @run-at       document-end
// ==/UserScript==
/*

这个脚本实现了四个网站的账号提取，通常都是需要通过调试工具拿到数据的请求方式，然后通过模拟请求进行获取数据
根据定制化的数据解析方法实现不同的网站采用不同的数据读取方法
//脚本更新地址 https://gitee.com/YaoDecheng/kf_zhanghao/raw/master/kf007-autoget.js

测试地址:

0
链接：https://kf.007.tools/s/ujmGLoMX&o=0593
密码：3RXOjD

1 http://103.20.61.147/share/share/index.html?token=xkyyjjc3bvedk5bgkah68tyx00schwgxg452gvg6hbkx7gszhr
2 https://qihang16.8888ws.net/agent/index.html
3 https://007.mn/staff-share-list?uuid=6dd6fc96e56f4e9db1863e701913b7d4&page=1&pageSize=10


*/
//版本更新
(function () {

    //默认链接头
    const def_headle = 'http://wa.me/+';
    //设置请求方式
    var method = 'GET';
    //定制化函数，需要在规则里实现
    let geturl, getList, getNumber, getOnlineStatus;
    //参数列表
    let requestHeader = {};
    let requestParams = {};
    var isOnline = 1;
    var isoffline = 2; //增加异常条件

    //规则实现
    const ruleList = [
        //规则****0
        {
            regex: new RegExp('https://kf.007.tools/shared-order*'),
            foo: function () {
                //设置请求方式
                method = 'GET';

                //设置请求头
                requestHeader = {
                    // 'agent-token': localStorage['agent-token'],
                }
                //请求参数
                requestParams = {
                    // page: 1,
                    // page_size: 1000
                }
                //选择插入按钮位置
                insertHtml(document.querySelector("#app"));

                //修改数据适配规则********************

                geturl = function () {
                    //从localStorage 拿到uuid和密码
                    const locurl = location.pathname;
                    const match = locurl.split("/shared-order/")
                    var order_id = '';

                    if (match) {
                        order_id = match[1];
                        console.log('order_id=' + order_id);
                        //return;
                    } else {
                        console.log("未找到order_id");
                        alert('未找到order_id');
                        return;
                    }

                    var uuid = getURLParameter(location.search, 'u');
                    var code = getURLParameter(location.search, 'code');

                    if (uuid == '' || uuid == null) {
                        alert('未找到uuid');
                        return;
                    }

                    if (code == '' || code == null) {
                        alert('未找到code');
                        return;
                    }

                    var passwd = sessionStorage[order_id + '_share_pwd'];
                    console.log("uuid=" + uuid);
                    console.log("code=" + code);
                    console.log('order_id=' + order_id);
                    console.log('passwd=' + passwd);

                    //请求连接
                    //https://kf.007.tools/counter-api/detail/user-detail/get_share_list?order_id=f661f68a35ae5c47c1a31f4dafb1b30bd404aaa74e900b33cd853969c58afe2e&share_pwd=3RXOjD&page=1&perpage=100
                    //https://kf.007.tools/counter-api/detail/user-detail/get_share_list?order_id=f661f68a35ae5c47c1a31f4dafb1b30bd404aaa74e900b33cd853969c58afe2e&uuid=0c6b95f5b5154b17b4c33f949ed5a1ea&code=ujmGLoMX&share_pwd=undefined&page=1&perpage=1000
                    //https://kf.007.tools/counter-api/detail/user-detail/get_share_list?order_id=f661f68a35ae5c47c1a31f4dafb1b30bd404aaa74e900b33cd853969c58afe2e&uuid=0c6b95f5b5154b17b4c33f949ed5a1ea&code=ujmGLoMX&share_pwd=3RXOjD&page=1&perpage=100

                    return 'https://kf.007.tools/counter-api/detail/user-detail/get_share_list?order_id=' + order_id + '&uuid=' + uuid + '&code=' + code + '&share_pwd=' + passwd + '&page=1&perpage=1000';
                }

                getList = function (data) {
                    return data.data.list;
                }

                getNumber = function (inten) {
                    return inten.line_account;
                }

                getOnlineStatus = function (inten) {
                    return inten.status;
                }
            }
        },
        //规则****1
        {
            regex: new RegExp('http://[^&]+/share/share/index.html'),
            foo: function () {

                //设置请求方式
                method = 'GET';


                //请求连接
                geturl = function () {
                    const url = '/share/share/api_yinliu_count.html?page=1&limit=1000';
                    return url;
                }

                //选择插入按钮位置
                insertHtml(document.body);

                //修改数据适配规则********************
                isOnline = 1;
                console.log("匹配离线状态")
                isOnline2 = 2; //把离线的也算上
                getList = function (data) {
                    return data.data;
                }
                getNumber = function (inten) {
                    return inten.user;
                }
                getOnlineStatus = function (inten) {
                    return inten.online;
                }
            }
        },
        //规则****2
        {
            regex: RegExp('https://qihang16.8888ws.net/agent/index.html*'),
            foo: function () {
                //设置请求方式
                method = 'POST';

                //请求连接
                geturl = function () {
                    const url = 'https://apiqihang16.8888ws.net/agent/wa.json';
                    return url;
                }
                //设置请求头
                requestHeader = {
                    'agent-token': localStorage['agent-token'],
                }
                //请求参数
                requestParams = {
                    page: 1,
                    page_size: 1000
                }
                //选择插入按钮位置
                insertHtml(document.querySelector("body > div.right.pull-left"));

                //修改数据适配规则********************
                isOnline = '在线';
                getList = function (data) {
                    return data.data.list;
                }

                getNumber = function (inten) {
                    return inten.mobile;
                }

                getOnlineStatus = function (inten) {
                    return inten.state_text;
                }
            }
        },
        //规则****3
        {
            regex: new RegExp('https://007.mn/staff-share-list*'),
            foo: function () {
                //设置请求方式
                method = 'GET';


                //请求连接
                geturl = function () {
                    //从localStorage 拿到uuid和密码
                    var uuid = getURLParameter(location.search, 'uuid');
                    var passwd = localStorage[uuid];
                    const url = '/java-api/staff/get_share_list?page=1&per_page=1000&uuid=' + uuid + '&password=' + passwd;
                    return url;
                }

                //选择插入按钮位置
                insertHtml(document.body.querySelector('.app-container'));

                //修改数据适配规则********************
                isOnline = 1;
                getList = function (data) {
                    return data.data.list;
                }

                getNumber = function (inten) {
                    return inten.username;
                }

                getOnlineStatus = function (inten) {
                    return inten.online_status;
                }
            }
        },
        //规则****4
        /**
链接：https://url05.top/b/wjLfBWkv2697/5
密码：1234
         */
        {
            regex: new RegExp('https://007.mn/ws-add-fans-detail-share-list'),
            foo: function () {
                //设置请求方式
                method = 'GET';


                //请求连接
                geturl = function () {

                    var uuid = getURLParameter(location.search, 'uuid');
                    var sid = getURLParameter(location.search, 'sid');
                    const passwd = localStorage[uuid]

                    console.log("uuid=" + uuid);
                    console.log("sid=" + sid);
                    console.log('passwd=' + passwd);

                    //const url = '/java-api/staff/get_share_list?page=1&per_page=1000&uuid=' + uuid + '&password=' + passwd;
                    //             /java-api/shunt/fans_details_list?page=2&per_page=10&link_uuid=ee2fe11551a74dae8c4ea59517ed6d36&sid=377cc65d17114401b5f99f08479f7730&password=1234
                    //             /java-api/shunt/fans_details_list?page=1&per_page=1000&link_uuid=ee2fe11551a74dae8c4ea59517ed6d36&sid377cc65d17114401b5f99f08479f7730&password=1234
                    const url = '/java-api/shunt/fans_details_list?page=1&per_page=1000&link_uuid=' + uuid + '&sid=' + sid + '&password=' + passwd;
                    return url;
                }

                //选择插入按钮位置
                insertHtml(document.body.querySelector('.app-container'));

                //修改数据适配规则********************
                isOnline = 1;
                getList = function (data) {
                    return data.data.list;
                }

                getNumber = function (inten) {
                    return inten.username;
                }

                getOnlineStatus = function (inten) {
                    return inten.online_status;
                }
            }
        },
        /*
        规则5
        链接：https://url04.top/b/NgAAaAQV1168/3
        密码：112233
        https://007.mn/shated-staff-list?uuid=9091496b57db43cbb1a23c26d20502e1&page=2&pageSize=10
        */
        {
            regex: new RegExp('https://007.mn/shated-staff-list*'),
            foo: function () {
                //设置请求方式
                method = 'GET';


                //请求连接
                geturl = function () {

                    var uuid = getURLParameter(location.search, 'uuid');
                    var passwd = getCookie(uuid);
                    console.log("uuid=" + uuid);
                    console.log('passwd=' + passwd);
                    //            java-api/staff/staff-share/get_account?page=2&per_page=10&uuid=9091496b57db43cbb1a23c26d20502e1&password=
                    //https://007.mn/java-api/staff/staff-share/get_account?page=2&per_page=10&uuid=9091496b57db43cbb1a23c26d20502e1&password=112233
                    // https://007.mn/java-api/staff/staff-share/get_account?page=1&per_page=1000&uuid=9091496b57db43cbb1a23c26d20502e1&password=undefined
                    const url = '/java-api/staff/staff-share/get_account?page=1&per_page=1000&uuid=' + uuid + '&password=' + passwd;
                    return url;
                }

                //选择插入按钮位置
                insertHtml(document.body.querySelector('.app-container'));

                //修改数据适配规则********************
                isOnline = 1;
                getList = function (data) {
                    return data.data.list;
                }

                getNumber = function (inten) {
                    return inten.username;
                }

                getOnlineStatus = function (inten) {
                    return inten.online_status;
                }
            }
        },
        /**
         规则6
         https://007.ma/ws-add-fans-detail-share-list?uuid=2d30b028b0cc4aa7a33d263efefbc015&sid=e9b0081fdc954bad93793c5cec3a8cf4

         */

        {
            regex: new RegExp('https://007.ma/ws-add-fans-detail-share-list*'),
            foo: function () {
                //设置请求方式
                method = 'GET';


                //请求连接
                geturl = function () {

                    var link_uuid = getURLParameter(location.search, 'uuid');
                    var password = localStorage[link_uuid];
                    var sid = getURLParameter(location.search, 'sid');
                    console.log("link_uuid=" + link_uuid);
                    console.log('passwd=' + password);
                    console.log('sid=' + sid);
                    // https://007.ma/java-api/shunt/get_fans_total?link_uuid=2d30b028b0cc4aa7a33d263efefbc015&password=123123&sid=e9b0081fdc954bad93793c5cec3a8cf4&username=
                    //https://007.ma/java-api/shunt/fans_details_list?page=1&per_page=50&link_uuid=2d30b028b0cc4aa7a33d263efefbc015&password=123123&sid=e9b0081fdc954bad93793c5cec3a8cf4&username=
                    //https://007.ma/java-api/shunt/get_fans_total?page=1&per_page=1000&link_uuid=2d30b028b0cc4aa7a33d263efefbc015&password=123123&sid=e9b0081fdc954bad93793c5cec3a8cf4&username=
                    const url = '/java-api/shunt/fans_details_list?page=1&per_page=1000&link_uuid=' + link_uuid + '&password=' + password + '&sid=' + sid + '&username=';
                    return url;
                }

                //选择插入按钮位置
                insertHtml(document.body.querySelector('.app-container'));

                //修改数据适配规则********************
                isOnline = 1;
                getList = function (data) {
                    return data.data.list;
                }

                getNumber = function (inten) {
                    return inten.username;
                }

                getOnlineStatus = function (inten) {
                    return inten.online_status;
                }
            }
        },
        /**
         规则7
         https://imx.chat/ws-add-fans-detail-share-list?uuid=65b21a741bfb4eab91e4ab83fc91fa48&sid=0bdd5c480f1541b7be82184614367e10
         */

        {
            regex: new RegExp('https://imx.chat/ws-add-fans-detail-share-list*'),
            foo: function () {
                //选择插入按钮位置
                insertHtml(document.body);
                //设置请求方式
                method = 'GET';


                //请求连接
                geturl = function () {

                    var link_uuid = getURLParameter(location.search, 'uuid');
                    var password = localStorage[link_uuid];
                    var sid = getURLParameter(location.search, 'sid');
                    console.log("link_uuid=" + link_uuid);
                    console.log('passwd=' + password);
                    console.log('sid=' + sid);
                    // https://007.ma/java-api/shunt/get_fans_total?link_uuid=2d30b028b0cc4aa7a33d263efefbc015&password=123123&sid=e9b0081fdc954bad93793c5cec3a8cf4&username=
                    //https://007.ma/java-api/shunt/fans_details_list?page=1&per_page=50&link_uuid=2d30b028b0cc4aa7a33d263efefbc015&password=123123&sid=e9b0081fdc954bad93793c5cec3a8cf4&username=
                    //https://007.ma/java-api/shunt/get_fans_total?page=1&per_page=1000&link_uuid=2d30b028b0cc4aa7a33d263efefbc015&password=123123&sid=e9b0081fdc954bad93793c5cec3a8cf4&username=
                    const url = '/java-api/shunt/fans_details_list?page=1&per_page=1000&link_uuid=' + link_uuid + '&password=' + password + '&sid=' + sid + '&username=';
                    return url;
                }



                //修改数据适配规则********************
                isOnline = 1;
                getList = function (data) {
                    return data.data.list;
                }

                getNumber = function (inten) {
                    return inten.username;
                }

                getOnlineStatus = function (inten) {
                    return inten.online_status;
                }
            }
        },
        /**
        规则8
       https://imx.chat/work-order-sharing?sid=1752343013804908545&workId=1750182529613864961
        */

        {
            regex: new RegExp('https://imx.chat/work-order-sharing*'),
            foo: function () {
                //选择插入按钮位置
                insertHtml(document.body);
                //设置请求方式
                method = 'POST';

                //设置请求头
                requestHeader = {
                    "Accept": "application/json, text/plain, */*",
                    'Uuid': JSON.parse(localStorage["share_jsq__" + getURLParameter(location.search, 'sid') + "___" + getURLParameter(location.search, 'workId')]).uuid,                                       //"8e6170c2c4d643efafa607b5e4080eec",
                    "Content-Type": "application/json;charset=UTF-8"
                }

                //请求参数
                requestParams = {
                    page: 1,
                    per_page: 1000,
                    workId: getURLParameter(location.search, 'workId')
                }


                //请求连接
                geturl = function () {
                    const url = 'new-ws-api/counter/work-share/open/detail';
                    return url;
                }



                //修改数据适配规则********************
                isOnline = 1;
                getList = function (data) {
                    return data.data.list;
                }

                getNumber = function (inten) {
                    return inten.account;
                }

                getOnlineStatus = function (inten) {
                    return inten.isOnline;
                }
            }
        },
        /**
       规则9
      https://admin.scrmchampion.com/shared-order/959a199f69e90222fcd893df29975026a4213074b64d53492f2643d996c23432?u=0c6b95f5b5154b17b4c33f949ed5a1ea&code=dQbgPZka
       */

        {
            regex: new RegExp('https://admin.scrmchampion.com/shared-order*'),
            foo: function () {
                //选择插入按钮位置
                insertHtml(document.body);
                //设置请求方式
                method = 'GET';

                //设置请求头
                requestHeader = {
                    // "Accept": "application/json, text/plain, */*",
                    // 'Uuid': "8e6170c2c4d643efafa607b5e4080eec",
                    // "Content-Type":"application/json;charset=UTF-8"
                }

                //请求参数
                requestParams = {
                }


                //请求连接
                geturl = function () {
                    const order_id = location.pathname.split('/')[2]
                    const uuid = getURLParameter(location.search, 'u')
                    const code = getURLParameter(location.search, 'code')
                    const share_pwd = sessionStorage[order_id + "_share_pwd"]
                    // https://admin.scrmchampion.com/counter-api/detail/user-detail/get_share_list?order_id=959a199f69e90222fcd893df29975026a4213074b64d53492f2643d996c23432&uuid=0c6b95f5b5154b17b4c33f949ed5a1ea&code=dQbgPZka&share_pwd=3bmddR&page=1&perpage=50
                    const url = 'counter-api/detail/user-detail/get_share_list?order_id=' + order_id + '&uuid=' + uuid + '&code=' + code + '&share_pwd=' + share_pwd + '&page=1&perpage=1000';
                    return url;
                }



                //修改数据适配规则********************
                isOnline = 1;
                getList = function (data) {
                    return data.data.list;
                }

                getNumber = function (inten) {
                    return inten.line_account;
                }

                getOnlineStatus = function (inten) {
                    return inten.status;
                }
            }
        },

        /**
       规则10
  https://app.imx.chat/work-order-sharing?sid=1771386678077370369&workId=1771015777449320449&page=2&pageSize=10
       */

        {
            regex: new RegExp('https://app.imx.chat/work-order-sharing*'),
            foo: function () {
                //选择插入按钮位置
                insertHtml(document.body);
                //设置请求方式
                method = 'POST';

                //设置请求头
                requestHeader = {
                    "Accept": "application/json, text/plain, */*",
                    'Uuid': JSON.parse(localStorage["share_jsq__" + getURLParameter(location.search, 'sid') + "___" + getURLParameter(location.search, 'workId')]).uuid,                                       //"8e6170c2c4d643efafa607b5e4080eec",
                    "Content-Type": "application/json;charset=UTF-8"
                }

                //请求参数
                requestParams = {
                    page: 1,
                    per_page: 1000,
                    workId: getURLParameter(location.search, 'workId')
                }


                //请求连接
                geturl = function () {
                    const url = 'new-ws-api/counter/work-share/open/detail';
                    return url;
                }



                //修改数据适配规则********************
                isOnline = 1;
                getList = function (data) {
                    return data.data.list;
                }

                getNumber = function (inten) {
                    return inten.account;
                }

                getOnlineStatus = function (inten) {
                    return inten.isOnline;
                }
            }
        },
        /**
           规则11
      https://app.imx.chat/ws-add-fans-detail-share-list?uuid=ee2fe11551a74dae8c4ea59517ed6d36&sid=50c1f659473e45548b5d2efc3e5bd6f6&page=2&pageSize=10
      https://app.imx.chat/java-api/shunt/fans_details_list?page=1&per_page=10&link_uuid=ee2fe11551a74dae8c4ea59517ed6d36&password=16888&sid=50c1f659473e45548b5d2efc3e5bd6f6&username=    
      */

        {
            regex: new RegExp('https://app.imx.chat/ws-add-fans-detail-share-list*'),
            foo: function () {
                //选择插入按钮位置
                insertHtml(document.body);
                //设置请求方式
                method = 'GET';

                //设置请求头
                requestHeader = {

                }

                //请求参数
                requestParams = {

                }


                //请求连接
                geturl = function () {
                    var uuid = getURLParameter(location.search, 'uuid');
                    var sid = getURLParameter(location.search, 'sid');
                    console.log("uuid=" + uuid);
                    console.log('sid=' + sid);
                    var passwd = localStorage[uuid];
                    console.log('passwd=' + passwd);


                    const url = 'java-api/shunt/fans_details_list?page=1&per_page=1000&link_uuid=' + uuid + '&password=' + passwd + '&sid=' + sid + '&username=';
                    return url;
                }



                //修改数据适配规则********************
                isOnline = 1;
                getList = function (data) {
                    return data.data.list;
                }

                getNumber = function (inten) {
                    return inten.username;
                }

                getOnlineStatus = function (inten) {
                    return inten.online_status;
                }
            }
        },
        /**
      规则12
 工单链接：https://www.haiwang.app/web#/accountshow/CMLLeuauV
  访问密码：888888
      */

        {
            regex: new RegExp('https://www.haiwang.app/web#/accountshow/*'),
            foo: function () {


                //选择插入按钮位置
                insertHtml(document.body);
                //设置请求方式
                method = 'GET';

                //设置请求头
                // requestHeader = {
                //     "Accept": "application/json, text/plain, */*",
                //     'Uuid': JSON.parse(localStorage["share_jsq__" + getURLParameter(location.search, 'sid') + "___" + getURLParameter(location.search, 'workId')]).uuid,                                       //"8e6170c2c4d643efafa607b5e4080eec",
                //     "Content-Type": "application/json;charset=UTF-8"
                // }

                // //请求参数
                // requestParams = {
                //     page: 1,
                //     per_page: 1000,
                //     workId: getURLParameter(location.search, 'workId')
                // }


                //请求连接
                geturl = function () {

                    const sharekey = location.hash.replace('#/accountshow/', '');//CMLLeuauV
                    console.log("sharekey=" + sharekey);


                    const cookieList = document.cookie.split(';')

                    const passwordtemp = cookieList[cookieList.length - 1].replace(' ', '')
                    const parts = passwordtemp.split('=');

                    const shareid = parts[0].split('_')[0]
                    const password = parts[1]
                    console.log("shareid=" + shareid);
                    console.log("password=" + password);

                    //list?page=1&limit=10&sort=acclist_id%20DESC&sharekey=CMLLeuauV&shareid=8971&password=888888
                    //https://www.haiwang.app/list?page=1&limit=150&sort=acclist_id%20DESC&sharekey=CMLLeuauV&shareid=8971&password=888888
                    //https://www.haiwang.app/web/accountshow/list?page=1&limit=150&sort=acclist_id%20DESC&sharekey=CMLLeuauV&shareid=8971&password=888888
                    const url = 'web/accountshow/list?page=1&limit=1000&sort=acclist_id%20DESC&sharekey=' + sharekey + '&shareid=' + shareid + '&password=' + password;
                    return url;
                }



                //修改数据适配规则********************
                isOnline = 2;
                isoffline = 0
                getList = function (data) {
                    return data.data.items;
                }

                getNumber = function (inten) {
                    return inten.acclist_id;
                }

                getOnlineStatus = function (inten) {
                    return inten.acclist_status;
                }
            }
        },
        // 13
        {
            regex: new RegExp('https://[^&]+/share/share/index.html'),
            foo: function () {

                //设置请求方式
                method = 'GET';


                //请求连接
                geturl = function () {
                    const url = '/share/share/api_yinliu_count.html?page=1&limit=1000';
                    return url;
                }

                //选择插入按钮位置
                insertHtml(document.body);

                //修改数据适配规则********************
                isOnline = 1;
                console.log("匹配离线状态")
                isOnline2 = 2; //把离线的也算上
                getList = function (data) {
                    return data.data;
                }
                getNumber = function (inten) {
                    return inten.user;
                }
                getOnlineStatus = function (inten) {
                    return inten.online;
                }
            }
        },

        /**
      规则14
       https://app.imx.chat/staff-share-list?uuid=8e45998db6414f819797d6e3006d5e9a
      */
        {
            regex: new RegExp('https://app.imx.chat/staff-share-list*'),
            foo: function () {
                //选择插入按钮位置
                insertHtml(document.body);
                //设置请求方式
                method = 'GET';



                const uuid = getURLParameter(location.search, 'uuid')
                console.log("uuid=", uuid);
                const passwd = localStorage[uuid]
                console.log("passwd=", passwd);


                //请求连接
                //https://app.imx.chat/java-api/staff/get_share_list?page=1&per_page=10&uuid=8e45998db6414f819797d6e3006d5e9a&password=123123
                geturl = function () {
                    const url = 'java-api/staff/get_share_list?page=1&per_page=1000&uuid=' + uuid + '&password=' + passwd;
                    return url;
                }



                //修改数据适配规则********************
                isOnline = 1;
                getList = function (data) {
                    return data.data.list;
                }

                getNumber = function (inten) {
                    return inten.username;
                }

                getOnlineStatus = function (inten) {
                    return inten.online_status;
                }
            }
        },

        {
            regex: new RegExp('http://url66.me/s*'),
            foo: function () {
                //设置请求方式
                method = 'GET';

                //设置请求头
                requestHeader = {
                    // 'agent-token': localStorage['agent-token'],
                }
                //请求参数
                requestParams = {
                    // page: 1,
                    // page_size: 1000
                }
                //选择插入按钮位置
                insertHtml(document.body);
                var  sharePassword = '123654'
                //插入输入监听
                {
                    // 使用querySelector选择特定的输入控件
                    var inputElement = document.querySelector("body > div.el-dialog__wrapper > div > div.el-dialog__body > form > div > div > div > input");

                    // 检查是否成功选择了元素
                    if (inputElement) {
                        // 为输入控件添加input事件监听器
                        inputElement.addEventListener('input', function (event) {
                            // event.target是触发事件的元素，这里就是inputElement
                            var inputValue = event.target.value;

                            // 在这里处理输入值，例如打印到控制台
                            console.log("密码等于:", inputValue);
                            sharePassword=inputValue;

                            // 你可以在这里添加更多的逻辑，比如验证输入内容等
                        });
                    } else {
                        console.log("输入控件未找到");
                    }
                }

                //修改数据适配规则********************
                geturl = function () {
                    //写各种获取信息的代码
                    const shareid = getURLParameter(location.search, 'id')
                    

                    //拼接完成返回链接地址
                    //return 'prod-api1/biz/link/share?shareId=11451&sharePassword=123654&pageNum=1&pageSize=10'
                    return 'prod-api1/biz/link/share?shareId=' + shareid + '&sharePassword=' + sharePassword + '&pageNum=1&pageSize=1000'

                }

                //在线标识定义
                isOnline = 1;
                //返回数据所在列表的位置
                getList = function (data) {
                    return data.list.rows;
                }
                //返回号码所在字段位置
                getNumber = function (inten) {
                    return inten.login;
                }
                //返回在线状态所在字段的位置
                getOnlineStatus = function (inten) {
                    return inten.onlineType;
                }
            }
        },
    //15***************************
        {
            regex: new RegExp('https://app.imx.chat/shated-staff-list*'),
            foo: function () {
                //设置请求方式
                method = 'GET';
        
                //设置请求头
                requestHeader = {
                    // 'agent-token': localStorage['agent-token'],
                }
                //请求参数
                requestParams = {
                    // page: 1,
                    // page_size: 1000
                }
                //选择插入按钮位置
                insertHtml(document.body);
        
                //修改数据适配规则********************
                geturl = function () {
                    //写各种获取信息的代码
                    const uuid=getURLParameter(location.search, 'uuid')
                    //在cookie中获取password
                    const password=getCookie(uuid)
                    
                    //拼接 java-api/staff/staff-share/get_account?page=1&per_page=10&uuid=93b5bd5955c942049a6ea91e7050d4b4&password=aa123123&username=
                    return 'java-api/staff/staff-share/get_account?page=1&per_page=1000&uuid='+uuid+'&password='+password+'&username='
                }
                 
                //在线标识定义
                isOnline = 1;
                //返回数据所在列表的位置
                getList = function (data) {
                    return data.data.list;
                }
                //返回号码所在字段位置
                getNumber = function (inten) {
                    return inten.username;
                }
                //返回在线状态所在字段的位置
                getOnlineStatus = function (inten) {
                    return inten.online_status;
                }
            }
        },
        //17********************
        {
            regex: new RegExp('https://admin.scrmchampion.com/share-activation-code/*'),
            foo: function () {
                //设置请求方式
                method = 'GET'; //POST
        
                //设置请求头
                requestHeader = {
                    // 'agent-token': localStorage['agent-token'],
                }
                //请求参数
                requestParams = {
                    // page: 1,
                    // page_size: 1000
                }
                //选择插入按钮位置
                insertHtml(document.body);
        
                //修改数据适配规则********************
                geturl = function () {
                    //写各种获取信息的代码
                    // getCookie("value_name");  //从cookie拿数据
                    // localStorage["value_name"];  //在本地存储拿数据
                    // sessionStorage["value_name"];  //在会话存储拿数据
                    // getURLParameter(location.search, 'value_name');//在连接地址拿数据
                    const uuid=getURLParameter(location.search, 'u')
                    const code=getURLParameter(location.search, 'c')
                    console.log("uuid等于:", uuid);
                    console.log("code等于:", code);
                    const password=sessionStorage[code+'_share_pwd']

                    //打印
                 
                    console.log("password等于:", password);
                    
                    //拼接完成返回链接地址
                    //https://admin.scrmchampion.com/counter-api/detail/user-detail/get_share_code_list?software_code=DQVkf5OANsQXrZflnqjWGA==&uuid=aa16994648ee4a28b2ac4fc96cc15ffb&share_pwd=3PnHDP&platform=1&platform=0&platform=6&platform=3&platform=2&platform=4&platform=5&platform=7&platform=9&platform=10&platform=11&platform=12&platform=13&platform=17&platform=16&&status=1&page=1&per_page=10
                    return 'https://admin.scrmchampion.com/counter-api/detail/user-detail/get_share_code_list?software_code=DQVkf5OANsQXrZflnqjWGA==&uuid=' + uuid + '&share_pwd=' + password + '&platform=1&platform=0&platform=6&platform=3&platform=2&platform=4&platform=5&platform=7&platform=9&platform=10&platform=11&platform=12&platform=13&platform=17&platform=16&&status=1&page=1&per_page=1000'
                }
                 
                //在线标识定义
                isOnline = 1;
                //返回数据所在列表的位置
                getList = function (data) {
                    return data.data.list;
                }
                //返回号码所在字段位置
                getNumber = function (inten) {
                    return inten.line_account;
                }
                //返回在线状态所在字段的位置
                getOnlineStatus = function (inten) {
                    return inten.status;
                }
            }
        },
    ]






    // #        ┏┓　　　┏┓+ +
    // #　　　┏┛┻━━━┛┻┓ + +
    // #　　　┃　　　　　　　┃
    // #　　　┃　　　━　　　┃ ++ + + +
    // #　　 ████━████ ┃+
    // #　　　┃　　　　　　　┃ +
    // #　　　┃　　　┻　　　┃
    // #　　　┃　　　　　　　┃ + +
    // #　　　┗━┓　　　┏━┛
    // #　　　　　┃　　　┃
    // #　　　　　┃　　　┃ + + + +
    // #　　　　　┃　　　┃
    // #　　　　　┃　　　┃ + 　　　　摸鱼神兽,极限摸鱼，下班的代码不用动
    // #　　　　　┃　　　┃
    // #　　　　　┃　　　┃　　+
    // #　　　　　┃　 　　┗━━━┓ + +
    // #　　　　　┃ 　　　　　　　┣┓
    // #　　　　　┃ 　　　　　　　┏┛
    // #　　　　　┗┓┓┏━┳┓┏┛ + + + +
    // #　　　　　　┃┫┫　┃┫┫
    // #　　　　　　┗┻┛　┗┻┛+ + + +
    // #　　　　　　┗┻┛　┗┻┛+ + + +

    //*****************************************************************************************************************************************/
    var flag = 0;
    for (const index in ruleList) {
        if (Object.hasOwnProperty.call(ruleList, index)) {
            // console.log(ruleList[index].regex)
            if (ruleList[index].regex.test(location.href)) {
                console.log(index + '号匹配网站成功' + ruleList[index].regex)
                ruleList[index].foo();
                console.log("初始化参数完成")
                flag = 1;
                break;
            }

        }
    }
    if (flag == 0) {
        console.log('没有匹配任何网站！')
        return;
    }

    // onclick 响应函数
    function onclick(mode) {

        console.log('模式=', mode);

        let xhr = new XMLHttpRequest();
        const url = geturl();
        if (url == null || url == '') {
            return;
        }
        xhr.open(method, url, true);
        for (const key in requestHeader) {
            if (Object.hasOwnProperty.call(requestHeader, key)) {
                const element = requestHeader[key];
                xhr.setRequestHeader(key, element);
            }
        }

        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    // console.log(xhr.responseText);
                    // 获取服务器响应的数据
                    if (mode == 2) {
                        xhr_data2(xhr.responseText);
                    }
                    else {
                        xhr_data(xhr.responseText);
                    }

                }
                else {
                    console.log('请求错误' + xhr.status);
                    alert('请求错误' + xhr.responseText);
                }
            }
        }
        xhr.send(JSON.stringify(requestParams));
    };

    //xhr请求返回解析
    function xhr_data(data) {
        const fans_data = JSON.parse(data);
        var page_cnt = 0;
        const page_size = 10;
        try {

            const list = getList(fans_data);
            let out = '\n'
            let count = 0;
            list.forEach(function (inten) {

                const number = getNumber(inten);
                const online_status = getOnlineStatus(inten);

                if (online_status == isOnline) {
                    console.log(number, '在线')
                    out = out + document.querySelector('#headle_url').value + number + '\n';
                    count = count + 1;
                    // if (count % 10 == 0) {
                    //     out = out + '\n';
                    // }
                }
                else {
                    console.error(number, '其他=' + online_status)
                }
                page_cnt++;
                if ((page_cnt % page_size) == 0) {
                    out = out + '\n';
                }

            })

            out = count + '个客服:' + out;
            console.log(out);
            copyToClipboard(out, '复制成功：\n' + out);

        } catch (error) {
            alert('json 解析出错\n' + data);
        }

    }
    function xhr_data2(data) {
        const fans_data = JSON.parse(data);
        var page_cnt = 0;
        const page_size = 10;
        try {

            const list = getList(fans_data);
            let out = '\n'
            let count = 0;
            list.forEach(function (inten) {

                const number = getNumber(inten);
                const online_status = getOnlineStatus(inten);

                if (online_status == isOnline) {

                    console.log(number, '在线')
                    out = out + document.querySelector('#headle_url').value + number + '\n';
                    count = count + 1;
                    // if (count % 10 == 0) {
                    //     out = out + '\n';
                    // }
                }
                else if (online_status == isoffline) {
                    console.warn(number, '取离线')
                    out = out + document.querySelector('#headle_url').value + number + '\n';
                    count = count + 1;
                }
                else {
                    console.error(number, '其他=' + online_status)
                }
                page_cnt++;
                if ((page_cnt % page_size) == 0) {
                    out = out + '\n';
                }

            })

            out = count + '个客服:' + out;
            console.log(out);
            copyToClipboard(out, '复制成功：\n' + out);

        } catch (error) {
            alert('json 解析出错\n' + data);
        }

    }
    //获取cookie值
    function getCookie(cookieName) {
        const strCookie = document.cookie
        const cookieList = strCookie.split(';')

        for (let i = 0; i < cookieList.length; i++) {
            const arr = cookieList[i].split('=')
            if (cookieName === arr[0].trim()) {
                return arr[1]
            }
        }

        return ''
    }

    //
    function getURLParameter(url, parameterName) {
        parameterName = parameterName.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
        var regex = new RegExp('[\\?&]' + parameterName + '=([^&#]*)');
        var results = regex.exec(url);
        return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
    }
    //复制剪贴板函数
    async function copyToClipboard(content, message) {
        const textarea = document.createElement('textarea');
        textarea.value = content;
        document.body.appendChild(textarea);
        textarea.select();
        try {
            await document.execCommand('copy');
            if (message == null) {
                alert('复制成功');
            } else {
                alert(message);
            }
        } catch (err) {
            console.error('复制失败:', err);
        }
        document.body.removeChild(textarea);
    }



    //复制内容到剪贴板
    async function copyToClipboardWithNewlines(content, message) {
        const textarea = document.createElement('textarea');
        textarea.style.position = 'fixed';
        textarea.style.top = 0;
        textarea.style.left = 0;
        textarea.style.width = '2em';
        textarea.style.height = '2em';
        textarea.style.padding = 0;
        textarea.style.border = 'none';
        textarea.style.outline = 'none';
        textarea.style.boxShadow = 'none';
        textarea.style.background = 'transparent';
        textarea.value = content;
        document.body.appendChild(textarea);
        textarea.select();
        textarea.setSelectionRange(0, content.length);

        try {
            await document.execCommand('copy');
            if (message == null) {
                alert('复制成功');
            } else {
                alert(message);
            }
        } catch (err) {
            console.error('复制失败:', err);
        }

        document.body.removeChild(textarea);
    }

    //插入html
    function insertHtml(location,) {
        // 生成style标签
        let style = document.createElement('style');
        // 把样式写进去
        style.innerText = `
.deleteBtn {
    border: 1px solid #0d6efd;
    cursor: pointer;
    color: #0d6efd;
    font-size: 14px;
    background-color: transparent;
    border-radius: 5px;
    transition: color .15s ease-in-out, background-color .15s ease-in-out;

}

.headleIpt {
    display: inline-block;
    width: 60%;

}

.headleIpt:focus {
    background-color: lightblue;
}

.deleteBtn:hover {
    background-color: #0d6efd;
    color: #fff;
}
`
        // 在head中添加style标签
        document.head.appendChild(style);

        //添加一個头标签
        let aabs = `
<div id="quhao" >
<lable for="headle_url" >输入头部:</lable>
<input  class="headleIpt" id="headle_url" value="http://ww+" />
<button type="button" class="fenxiBtn deleteBtn">提取信息</button>
<button type="button" class="fenxiBtn2 deleteBtn">包含离线</button>
</div>
`

        location.insertAdjacentHTML('afterbegin', aabs)
        document.querySelector('.fenxiBtn').addEventListener('click', function () {
            onclick();
        })
        document.querySelector('.fenxiBtn2').addEventListener('click', function () {
            onclick(2);
        })

        document.querySelector('#headle_url').value = def_headle


    }

})();

